package com.lhnstart.learn.bases.cycle;

/**
 * 杨辉三角形
 *
 * @author lhn
 * @date 2022/11/05 09:03
 * @since 1.0.0
 **/
public class YangHui {

    public static void main(String[] args) {
        boolean[] a = new boolean[3];
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

        int[][] yangHui = new int[10][];

        for (int i = 0; i < yangHui.length; i++) {
            // 给二位数组初始化
            yangHui[i] = new int[i + 1];
            // 给二维数组赋值
            for (int j = 0; j < yangHui[i].length; j++) {
                if (j == 0 || j == yangHui[i].length - 1) {
                    yangHui[i][j] = 1;
                } else {
                    yangHui[i][j] = yangHui[i - 1][j] + yangHui[i - 1][j - 1];
                }
            }
        }
        for (int i = 0; i < yangHui.length; i++) {
            for (int j = 0; j < yangHui[i].length; j++) {
                System.out.print(yangHui[i][j]+" ");
            }
            System.out.println();
        }
    }

}